package Netty.fastjson;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class NettyClientHandler extends SimpleChannelInboundHandler<Member> {


    @Override
    public void channelActive(ChannelHandlerContext ctx) {
        Member member=new Member();
        member.setName("lin");
        member.setAge(25);
        member.setMid("666");
        member.setSalary(12000D);

        System.out.println("netty client 启动...");
        ctx.channel().writeAndFlush(member);
    }
 

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Member msg) throws Exception {
        System.out.println("netty 服务器响应信息:"+msg);

    }


    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
        cause.printStackTrace();
        ctx.close();
    }

}